use diesel::{Insertable, Queryable, Selectable};
use serde::Serialize;

use crate::model::schema::schema::posts;

// 用于查询

#[derive(Debug, Insertable, Serialize, Queryable)]
#[diesel(table_name = posts)]
#[diesel(check_for_backend(diesel::pg::Pg))]
#[diesel(primary_key(id))]
pub struct Post {
    pub id: i64,
    #[diesel(column_name = title)]
    pub title: String,
    pub body: String,
    pub published: bool,
    pub status: bool,
}

// 用于创建
#[derive(Insertable)]
#[diesel(table_name = posts)]
pub struct NewPost<'a> {
    pub title: &'a str,
    pub body: &'a str,
}
